package it.low.util.logger;

import it.low.util.Constant;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ServerLogger extends Logger {
	
	static private FileLogHandler serverFileLogHandler;

	protected ServerLogger(String arg0, String arg1) {
		super(arg0, arg1);		
	}
	
	public static Logger getLogger(String name){
		Logger logger = Logger.getLogger(name);
		logger.setLevel(Level.INFO);
		String filePattern = "log/"+Constant.SERVER_LOG_FILE_NAME;
		try{			
			serverFileLogHandler = new FileLogHandler(filePattern);
			FileLogFormatter fileLogFormatter = new FileLogFormatter();
			serverFileLogHandler.setFormatter(fileLogFormatter);
			logger.addHandler(serverFileLogHandler);
		}catch(IOException ioe){
			logger.severe("Can't create log file " + filePattern);
			ioe.printStackTrace();
		}
		return logger;		
	}
		
		
	
	
}
